.class public Lcom/xiaomi/notes/CustomAutoLinkEditText;
.super Landroid/widget/EditText;
.source "CustomAutoLinkEditText.java"


# instance fields
.field private activity:Lcom/xiaomi/notes/NoteEditActivity;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 0
    .parameter "context"

    .prologue
    .line 30
    invoke-direct {p0, p1}, Landroid/widget/EditText;-><init>(Landroid/content/Context;)V

    .line 31
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 0
    .parameter "context"
    .parameter "attrs"

    .prologue
    .line 26
    invoke-direct {p0, p1, p2}, Landroid/widget/EditText;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 27
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 0
    .parameter "context"
    .parameter "attrs"
    .parameter "defStyle"

    .prologue
    .line 22
    invoke-direct {p0, p1, p2, p3}, Landroid/widget/EditText;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 23
    return-void
.end method

.method static synthetic access$000(Lcom/xiaomi/notes/CustomAutoLinkEditText;)Lcom/xiaomi/notes/NoteEditActivity;
    .locals 1
    .parameter "x0"

    .prologue
    .line 17
    iget-object v0, p0, Lcom/xiaomi/notes/CustomAutoLinkEditText;->activity:Lcom/xiaomi/notes/NoteEditActivity;

    return-object v0
.end method


# virtual methods
.method protected onCreateContextMenu(Landroid/view/ContextMenu;)V
    .locals 11
    .parameter "menu"

    .prologue
    const/4 v10, 0x0

    .line 65
    iget-object v8, p0, Lcom/xiaomi/notes/CustomAutoLinkEditText;->activity:Lcom/xiaomi/notes/NoteEditActivity;

    if-nez v8, :cond_0

    .line 66
    invoke-super {p0, p1}, Landroid/widget/EditText;->onCreateContextMenu(Landroid/view/ContextMenu;)V

    .line 117
    :goto_0
    return-void

    .line 71
    :cond_0
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getText()Landroid/text/Editable;

    move-result-object v8

    instance-of v8, v8, Landroid/text/Spanned;

    if-eqz v8, :cond_1

    .line 72
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getSelectionStart()I

    move-result v5

    .line 73
    .local v5, selStart:I
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getSelectionEnd()I

    move-result v4

    .line 75
    .local v4, selEnd:I
    invoke-static {v5, v4}, Ljava/lang/Math;->min(II)I

    move-result v3

    .line 76
    .local v3, min:I
    invoke-static {v5, v4}, Ljava/lang/Math;->max(II)I

    move-result v2

    .line 78
    .local v2, max:I
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getText()Landroid/text/Editable;

    move-result-object v8

    const-class v9, Landroid/text/style/URLSpan;

    invoke-interface {v8, v3, v2, v9}, Landroid/text/Spanned;->getSpans(IILjava/lang/Class;)[Ljava/lang/Object;

    move-result-object v7

    check-cast v7, [Landroid/text/style/URLSpan;

    .line 79
    .local v7, urls:[Landroid/text/style/URLSpan;
    array-length v8, v7

    const/4 v9, 0x1

    if-ne v8, v9, :cond_1

    .line 80
    aget-object v8, v7, v10

    invoke-virtual {v8}, Landroid/text/style/URLSpan;->getURL()Ljava/lang/String;

    move-result-object v6

    .line 81
    .local v6, url:Ljava/lang/String;
    const/4 v0, 0x0

    .line 82
    .local v0, cmdName:I
    const-string v8, "tel:"

    invoke-virtual {v6, v8}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v8

    if-ltz v8, :cond_3

    .line 83
    const v0, 0x7f05006a

    .line 91
    :goto_1
    invoke-interface {p1, v10, v10, v10, v0}, Landroid/view/ContextMenu;->add(IIII)Landroid/view/MenuItem;

    move-result-object v8

    new-instance v9, Lcom/xiaomi/notes/CustomAutoLinkEditText$1;

    invoke-direct {v9, p0, v7}, Lcom/xiaomi/notes/CustomAutoLinkEditText$1;-><init>(Lcom/xiaomi/notes/CustomAutoLinkEditText;[Landroid/text/style/URLSpan;)V

    invoke-interface {v8, v9}, Landroid/view/MenuItem;->setOnMenuItemClickListener(Landroid/view/MenuItem$OnMenuItemClickListener;)Landroid/view/MenuItem;

    .line 104
    .end local v0           #cmdName:I
    .end local v2           #max:I
    .end local v3           #min:I
    .end local v4           #selEnd:I
    .end local v5           #selStart:I
    .end local v6           #url:Ljava/lang/String;
    .end local v7           #urls:[Landroid/text/style/URLSpan;
    :cond_1
    iget-object v8, p0, Lcom/xiaomi/notes/CustomAutoLinkEditText;->activity:Lcom/xiaomi/notes/NoteEditActivity;

    invoke-virtual {v8}, Lcom/xiaomi/notes/NoteEditActivity;->isTextCanCallBack()Z

    move-result v1

    .line 105
    .local v1, flag:Z
    if-eqz v1, :cond_2

    .line 106
    const v8, 0x7f050055

    invoke-interface {p1, v10, v10, v10, v8}, Landroid/view/ContextMenu;->add(IIII)Landroid/view/MenuItem;

    move-result-object v8

    new-instance v9, Lcom/xiaomi/notes/CustomAutoLinkEditText$2;

    invoke-direct {v9, p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText$2;-><init>(Lcom/xiaomi/notes/CustomAutoLinkEditText;)V

    invoke-interface {v8, v9}, Landroid/view/MenuItem;->setOnMenuItemClickListener(Landroid/view/MenuItem$OnMenuItemClickListener;)Landroid/view/MenuItem;

    .line 116
    :cond_2
    invoke-super {p0, p1}, Landroid/widget/EditText;->onCreateContextMenu(Landroid/view/ContextMenu;)V

    goto :goto_0

    .line 84
    .end local v1           #flag:Z
    .restart local v0       #cmdName:I
    .restart local v2       #max:I
    .restart local v3       #min:I
    .restart local v4       #selEnd:I
    .restart local v5       #selStart:I
    .restart local v6       #url:Ljava/lang/String;
    .restart local v7       #urls:[Landroid/text/style/URLSpan;
    :cond_3
    const-string v8, "//"

    invoke-virtual {v6, v8}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v8

    if-ltz v8, :cond_4

    .line 85
    const v0, 0x7f05006c

    goto :goto_1

    .line 86
    :cond_4
    const-string v8, "mailto:"

    invoke-virtual {v6, v8}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v8

    if-ltz v8, :cond_5

    .line 87
    const v0, 0x7f05006b

    goto :goto_1

    .line 89
    :cond_5
    const v0, 0x7f05006d

    goto :goto_1
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .locals 8
    .parameter "event"

    .prologue
    .line 39
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v6

    packed-switch v6, :pswitch_data_0

    .line 60
    :cond_0
    :goto_0
    invoke-super {p0, p1}, Landroid/widget/EditText;->onTouchEvent(Landroid/view/MotionEvent;)Z

    move-result v6

    return v6

    .line 42
    :pswitch_0
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F

    move-result v6

    float-to-int v4, v6

    .line 43
    .local v4, x:I
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F

    move-result v6

    float-to-int v5, v6

    .line 44
    .local v5, y:I
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getTotalPaddingLeft()I

    move-result v6

    sub-int/2addr v4, v6

    .line 45
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getTotalPaddingTop()I

    move-result v6

    sub-int/2addr v5, v6

    .line 46
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getScrollX()I

    move-result v6

    add-int/2addr v4, v6

    .line 47
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getScrollY()I

    move-result v6

    add-int/2addr v5, v6

    .line 49
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getLayout()Landroid/text/Layout;

    move-result-object v0

    .line 50
    .local v0, layout:Landroid/text/Layout;
    invoke-virtual {v0, v5}, Landroid/text/Layout;->getLineForVertical(I)I

    move-result v1

    .line 51
    .local v1, line:I
    int-to-float v6, v4

    invoke-virtual {v0, v1, v6}, Landroid/text/Layout;->getOffsetForHorizontal(IF)I

    move-result v3

    .line 53
    .local v3, off:I
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getText()Landroid/text/Editable;

    move-result-object v6

    const-class v7, Landroid/text/style/ClickableSpan;

    invoke-interface {v6, v3, v3, v7}, Landroid/text/Editable;->getSpans(IILjava/lang/Class;)[Ljava/lang/Object;

    move-result-object v2

    check-cast v2, [Landroid/text/style/ClickableSpan;

    .line 54
    .local v2, link:[Landroid/text/style/ClickableSpan;
    array-length v6, v2

    if-eqz v6, :cond_0

    .line 55
    invoke-virtual {p0}, Lcom/xiaomi/notes/CustomAutoLinkEditText;->getText()Landroid/text/Editable;

    move-result-object v6

    invoke-static {v6, v3}, Landroid/text/Selection;->setSelection(Landroid/text/Spannable;I)V

    goto :goto_0

    .line 39
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
    .end packed-switch
.end method

.method public setActivity(Lcom/xiaomi/notes/NoteEditActivity;)V
    .locals 0
    .parameter "activity"

    .prologue
    .line 34
    iput-object p1, p0, Lcom/xiaomi/notes/CustomAutoLinkEditText;->activity:Lcom/xiaomi/notes/NoteEditActivity;

    .line 35
    return-void
.end method
